<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/jquery.js"></script>
</head>

<body>
    <form action="">
        <input type="text" name="uname">
        <input type="password" name="pwd">
        <button type="submit"></button>
    </form>
    <!-- 原生的: 一个一个来获取input内容 -->
    <!-- H5提供一次性快速获取表单数据的内容 -->
    <!-- JQ ①监听form标签的submit事件, 阻止事件默认行为, $(this).serialize() ==> 'uname=xxx&pwd=xxxx' -->


    <script>
        // 页面运行必须使用 vscode服务器启动
        $.ajax({
            method: "get",
            url: "http://www.liulongbin.top:3006/api/getbooks?a=1&b=2",
            data: {
                a: 1,
                b: 2
            },
            success: function (res) {
                console.log(res);
            }
        });

        var xhr = new XMLHttpRequest()
        xhr.open('GET', './1.json')
        xhr.send()
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4 && xhr.status === 200) {
                console.log(JSON.parse(xhr.responseText))
            }
        }
    </script>
</body>

</html>